package org.yxing.palpalgps.activity;

import org.yxing.palpalgps.R;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;

public class ChatsTabActivity extends TabActivity {
    
    private TabHost mTabHost;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chats_tab);
        
        mTabHost = getTabHost();
        
        mTabHost.addTab(mTabHost.newTabSpec("recent")
                .setIndicator(getIndicator("Recents", R.drawable.chats_tab_bg_left))
                .setContent(new Intent(this, RecentChatsActivity.class)));
        
        mTabHost.addTab(mTabHost.newTabSpec("group")
                .setIndicator(getIndicator("Group", R.drawable.chats_tab_bg_right))
                .setContent(new Intent(this, GroupChatsActivity.class)));
    }
    
    private View getIndicator(String label, int resid) {
        View v = getLayoutInflater().inflate(R.layout.chats_tab_indicator, null);
        v.setBackgroundResource(resid);
        TextView textViewLabel = (TextView) v.findViewById(R.id.textViewLabel);
        textViewLabel.setText(label);
        return v;
    }
    
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return false;
        }
        return super.onKeyUp(keyCode, event);
    }
}
